<template>
    <rx-layout>
        <div slot="header" style="text-align:right;">
            <a-button icon="save" @click="saveProps" type="primary">{{$ti18('rxForm.saveBtn','保存')}}</a-button>
        </div>
        <div slot="center" style="padding:5px;margin:5px;">
            <a-collapse v-model="panelActiveKeys">
                <a-collapse-panel v-if="isJpaasUser" key="1" :header="i18n('argsForm.baseConf','基础配置')">
                    <a-form>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.servAddr','服务端地址前缀')">
                                <a-input v-model="configs.serverAddress" :placeholder="i18n('argsForm.servAddr','服务端地址前缀')"
                                         v-decorator="[{rules: [{required: true, message: i18n('argsForm.servAddr','服务端地址前缀')}]}]"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.mobileUrl','移动端地址')">
                                <a-input :placeholder="i18n('argsForm.mobileUrl','移动端地址')" v-model="configs.mobileUrl" v-decorator="[{rules: [{required: true, message: i18n('argsForm.mobileUrl','移动端地址')}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.ctxPath','应用上下文路径')">
                                <a-input :placeholder="i18n('argsForm.ctxEntrance','ContextPath')" v-model="configs.ctxPath" v-decorator="[{rules: [{required: true, message: i18n('argsForm.ctxEntrance','ContextPath')}]}]"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.signAddress','签名地址')">
                                <a-input v-model="configs.signatureAddress" :placeholder="i18n('argsForm.signAddress','签名地址')"
                                         v-decorator="[{rules: [{required: true, message: i18n('argsForm.signAddress','签名地址')}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>

                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.logicDel','启用逻辑删除')">
                                <a-checkbox v-model="configs.logicDel" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.paramsEncrypt','是否参数加密')">
                                <a-checkbox v-model="configs.paramsEncrypt" />
                            </a-form-item>
                        </a-col>
                    </a-row>
                        <a-row :span="24" v-show="configs.paramsEncrypt" >

                            <a-col :span="24">
                                <a-form-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="i18n('argsForm.skipEncryptUrl','跳过加密的URL')">
                                    <a-input v-model="configs.encSkipUrl" :placeholder="i18n('argsForm.skipEncryptUrlPlaceholder','跳过加密的URL,使用逗号分隔')"
                                             v-decorator="[{rules: [{required: true, message: i18n('argsForm.skipEncryptUrl','签名地址')}]}]"/>
                                </a-form-item>
                            </a-col>
                        </a-row>
                        <a-row :span="24">
                            <a-col :span="12">
                                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.debugLevel','日志模式')">
                                    <a-radio-group v-model="configs.debugLevel" >
                                        <a-radio :value="'1'">debug</a-radio>
                                        <a-radio :value="'2'">info</a-radio>
                                        <a-radio :value="'3'">warn</a-radio>
                                        <a-radio :value="'4'">error</a-radio>
                                    </a-radio-group>
                                </a-form-item>
                            </a-col>
                            <a-col :span="12">
                                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.startTreeStatistic','开启分类树统计')">
                                    <a-checkbox v-model="configs.startTreeStatistic" />
                                </a-form-item>
                            </a-col>

                        </a-row>

                        <a-row :span="24">
                          <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.passwordMode','密码加密模式')">
                              <a-radio-group v-model="configs.passwordmode" >
                                <a-radio :value="'default'">{{i18n('argsForm.default','默认')}}</a-radio>
                                <a-radio :value="'md5'">MD5</a-radio>
                                <a-radio :value="'sm2'">SM2</a-radio>
                              </a-radio-group>
                            </a-form-item>
                          </a-col>
                        </a-row>
                </a-form>
                </a-collapse-panel>

                <a-collapse-panel v-if="isJpaasUser" key="3" :header="i18n('argsForm.smsConf','短信配置')">
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.smsType','短信配置方式')">
                                <a-radio-group v-model="configs.smsType" @change="typeChange">
                                    <a-radio :value="'qcloud'">{{i18n('argsForm.smsTx','腾讯短信配置')}}</a-radio>
                                    <a-radio :value="'aliyunSms'">{{i18n('argsForm.smsAly','阿里短信配置')}}</a-radio>
                                </a-radio-group>
                            </a-form-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="i18n('argsForm.smsSign','短信签名')">
                                <a-input :placeholder="i18n('argsForm.smsSign','短信签名')" v-model="configs.smsSign"
                                         v-decorator="[{rules: [{required: true, message: i18n('argsForm.smsSign','短信签名')}]}]"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="i18n('argsForm.smsTemplateId','短信模板ID')">
                                <a-input :placeholder="i18n('argsForm.smsTemplateId','短信模板ID')"
                                         v-model="configs.smsTemplateId"
                                         v-decorator="[{rules: [{required: true, message: i18n('argsForm.smsTemplateId','短信模板ID')}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="smsAppIdName">
                                <a-input :placeholder="smsAppIdName" v-model="configs.smsAppId"
                                         v-decorator="[{rules: [{required: true, message: smsAppIdName}]}]"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="smsAppKeyName">
                                <a-input :placeholder="smsAppKeyName"
                                         v-model="configs.smsAppKey"
                                         v-decorator="[{rules: [{required: true, message: smsAppKeyName}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24" v-if="configs.smsType=='aliyunSms'">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="i18n('argsForm.templateVarName','模板变量名')">
                                <a-input :placeholder="i18n('argsForm.templateVarValue','模板变量名，默认值：')+'code'" v-model="configs.smsCode"
                                         v-decorator="[{rules: [{required: true, message: this.i18n('argsForm.templateVarName','模板变量名','input')}]}]"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"
                                         :label="'Endpoint'">
                                <a-input :placeholder="'Endpoint '+i18n('argsForm.refer','请参考')+' https://api.aliyun.com/product/Dysmsapi'"
                                         v-model="configs.smsEndpoint"
                                         v-decorator="[{rules: [{required: true, message: 'Endpoint'}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-collapse-panel>
                <a-collapse-panel key="4" :header="i18n('argsForm.loginConf','登录配置')">
                    <a-row>
                    <a-col :span="12">
                        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.ignoreValidCode','忽略验证码')">
                            <a-radio-group v-model="siteSettingConfs.ignoreValidCode" button-style="solid">
                                <a-radio-button value="true">
                                    {{i18n('argsForm.yes','是')}}
                                </a-radio-button>
                                <a-radio-button value="false">
                                    {{i18n('argsForm.no','否')}}
                                </a-radio-button>
                            </a-radio-group>
                        </a-form-item>
                    </a-col>
                    <a-col :span="12" v-if="isJpaasUser" >
                        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.multipleLogin','是否允许多地登陆')">
                            <a-radio-group v-model="configs.multipleLogin" button-style="solid">
                                <a-radio-button value="true">
                                    {{i18n('argsForm.yes','是')}}
                                </a-radio-button>
                                <a-radio-button value="false">
                                    {{i18n('argsForm.no','否')}}
                                </a-radio-button>
                            </a-radio-group>
                        </a-form-item>
                    </a-col>
                </a-row>
                <a-row>
                    <a-col :span="12" v-if="isJpaasUser" >
                        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.tenantAdmin','租户管理员账号名')">
                            <a-input :placeholder="i18n('argsForm.tenantAdmin','租户管理员账号名')" v-model="configs.tenantAdmin" v-decorator="[{rules: [{required: true, message: 'tenantAdmin'}]}]"/>
                        </a-form-item>
                    </a-col>
                    <a-col :span="12">
                        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.defaultMainOrg','同步用户默认主部门')" prop="idsClientSecret">
                            <a-input-group compact style="display: flex;margin-top: 6px;" ref="idsGroupIdInput">
                                <a-input allowClear  v-model="inst.defaultGroupIdName" style="flex: 1;" />
                                <a-button @click="openDefaultGroup"  style="width: 50px">·&nbsp;·&nbsp;·</a-button>
                            </a-input-group>
                        </a-form-model-item>
                    </a-col>
                </a-row>
                </a-collapse-panel>
                <a-collapse-panel v-if="isJpaasUser"  key="5" :header="i18n('argsForm.attWhitelistConf','上传附件白名单配置')">
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.isCheckUploadWhiteList','是否开启上传白名单')">
                                <a-radio-group v-model="configs.isCheckUploadWhiteList" button-style="solid">
                                    <a-radio-button value="true">
                                        {{i18n('argsForm.yes','是')}}
                                    </a-radio-button>
                                    <a-radio-button value="false">
                                        {{i18n('argsForm.no','否')}}
                                    </a-radio-button>
                                </a-radio-group>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="i18n('argsForm.uploadWhiteList','上传白名单')">
                                <a-textarea :placeholder="i18n('argsForm.uploadWhiteList','上传白名单')" :rows="4" v-model="configs.uploadWhiteList" v-decorator="[{rules: [{required: true, message: i18n('argsForm.uploadWhiteList','上传白名单')}]}]"/>
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-collapse-panel>
                <a-collapse-panel key="6" :header="i18n('argsForm.loginPageConf','登录页配置')">
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-model-item :label="i18n('argsForm.loginPageTitle','登录页标题')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                                <a-input :placeholder="i18n('argsForm.loginPageTitle','登录页标题','input')" @change="updateI18nName(loginPageConfig,'loginPageTitle')" v-model="loginPageTitle">
                                    <my-icon slot="addonAfter" type="iconearth-full" @click="editI18nName(loginPageConfig,'loginPageTitle')" />
                                </a-input>
                            </a-form-model-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-model-item :label="i18n('argsForm.loginPageCopyright','登录页版权')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                                <a-input :placeholder="i18n('argsForm.loginPageCopyright','登录页版权','input')" @change="updateI18nName(loginPageConfig,'loginPageCopyright')" v-model="loginPageCopyright">
                                    <my-icon slot="addonAfter" type="iconearth-full" @click="editI18nName(loginPageConfig,'loginPageCopyright')"/>
                                </a-input>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-model-item :label="i18n('argsForm.backGroudLogo','登录页背景图')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                                <div class="uploadBox">
                                    <a-upload
                                        name="files"
                                        listType="picture-card"
                                        class="avatar-uploader"
                                        :showUploadList="false"
                                        action="/api/api-system/system/core/sysFile/upload"
                                        :headers="headers"
                                        :beforeUpload="beforeUploadBackGroup"
                                        @change="handleLoginBackGroup"
                                        style="width: 100%;height: 100%;"
                                    >
                                        <div v-if="loginBackGroupUrl" class="upload-del" @click.stop="imgDel()"><a-icon type="close-circle" /></div>
                                        <img v-if="loginBackGroupUrl" :src="loginBackGroupUrl" alt="photo"
                                             class="userHeadPortrait" style="max-width: 100%;object-fit: cover"/>
                                        <div v-else>
                                            <a-icon :type="loginBackGroupLoading ? 'loading' : 'plus'"/>
                                        </div>
                                    </a-upload>
                                </div>
                                <span class="avatar-uploader-span">{{i18n('argsForm.backGroupSizeTips','建议上传830*710的背景图片')}}</span>
                            </a-form-model-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-model-item :label="i18n('argsForm.colorLogo','登录页彩色logo')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                                <div class="uploadBox">
                                    <a-upload
                                        name="files"
                                        listType="picture-card"
                                        class="avatar-uploader"
                                        :showUploadList="false"
                                        action="/api/api-system/system/core/sysFile/upload"
                                        :headers="headers"
                                        :beforeUpload="beforeUploadLogo"
                                        @change="handleLoginPageLogo"
                                        style="width: 100%;height: 100%;"
                                    >
                                        <div v-if="loginPageLogoUrl" class="upload-del" @click.stop="imgDel('loginPageLogoUrl')"><a-icon type="close-circle" /></div>
                                        <img v-if="loginPageLogoUrl" :src="loginPageLogoUrl" alt="photo"
                                             class="userHeadPortrait" style="max-width: 100%;object-fit: cover"/>
                                        <div v-else>
                                            <a-icon :type="loginPageLogoLoading ? 'loading' : 'plus'"/>
                                        </div>
                                    </a-upload>
                                </div>
                                <span class="avatar-uploader-span">{{i18n('argsForm.sizeTips','建议上传50*50')}}</span>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                    <a-row :span="24">
                        <a-col :span="12">
                            <a-form-model-item :label="i18n('argsForm.version','版本')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                                <a-input  :placeholder="i18n('argsForm.version','版本','input')" v-model="loginPageConfig.homePageVersion" />
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                </a-collapse-panel>
            </a-collapse>
        </div>
    </rx-layout>
</template>

<script>
import {Util,Dialog,TokenUtil} from "@lowcode/jpaas-common-lib";
import userState from "@/assets/js/userState";

export default {
    name: "SysPropertiesPanel",
    mixins:[userState],
    props:['configsJson','siteSettingJson','osInst'],
    data(){
        return {
            panelActiveKeys:['1','2','3','4','5','6'],
            labelCol:{span:6},
            wrapperCol:{span:18},
            labelCol1:{span:3},
            wrapperCol1:{span:21},
            configs:{
                appName:'',
                multipleLogin:'false',
                isCheckUploadWhiteList:'false',
                smsCode:"code",
                smsEndpoint:"dysmsapi.aliyuncs.com",
            },
            siteSetting:{
            },
            siteSettingConfs:{
                ignoreValidCode:'false',
                loginPageConfig:{},
            },
            loginPageConfig:{
                loginPageTitle:"",
                loginPageCopyright:"",
                loginPageLogo:"",
                loginBackGroup:"",
                homePageVersion:"",
            },
            //用于显示当前语言的标题和版权
            loginPageTitle:"",
            loginPageCopyright:"",
            headers:{},
            loginPageLogoUrl: '',
            loginBackGroupUrl: '',
            loginPageLogoLoading:false,
            loginBackGroupLoading:false,
            i18nDefault:process.env.VUE_APP_LANGUAGE,
            smsAppIdName:"",
            smsAppKeyName:"",
            //是否平台用户
            isJpaasUser:false,
            isBeginWatchNum:0,
            inst:{

            },
            isInstOsInst:true,
        }
    },
    created() {
        this.initUser();
        this.initData();
    },
    methods:{
        i18n(name,text,key){
          return this.$ti18(name,text,"SysConfig",key);
        },
        openDefaultGroup(){
            let config ={
                single:true,
                dimId:'1',
                showDimId:false,
                tenantId:this.inst.instId
            }
            Dialog.openGroupDialog({curVm: this,data:config, widthHeight: ['1000px','600px']},function(self,data){
                self.$set(self.inst,'defaultGroupIdName',data.name);
                self.inst.defaultGroupId =data.groupId;

            })
        },
        initUser(){
            if(this.user && "1"===this.user.tenantId){
                this.isJpaasUser=true;
            }
        },
        initData(){
            var token =TokenUtil.getToken() ;
            if (token) {
                this.headers['Authorization'] = 'Bearer ' + token // 让每个请求携带token--['Authorization']为自定义key 请根据实际情况自行修改
            }
            this.getCurrentI18n();
            this.initSiteSetting();
            this.initInst();
            this.initConfigs();
            this.setSmsNames();
        },
        initInst(){
            this.inst =this.osInst;
        },
        initSiteSetting(){
            this.siteSetting=this.siteSettingJson;
            if(this.siteSetting.confs){
                this.siteSettingConfs = JSON.parse(this.siteSetting.confs);
            }
            //登录页配置
            if(this.siteSettingConfs.loginPageConfig){
                this.loginPageConfig=this.siteSettingConfs.loginPageConfig;
                if(this.loginPageConfig.loginPageTitle){
                    let loginPageTitleI18=eval("(" + this.loginPageConfig.loginPageTitle + ")");
                    this.loginPageTitle=loginPageTitleI18[this.i18nCurrent]
                }
                if(this.loginPageConfig.loginPageCopyright){
                    let loginPageCopyrightI18=eval("(" + this.loginPageConfig.loginPageCopyright + ")");
                    this.loginPageCopyright=loginPageCopyrightI18[this.i18nCurrent]
                }
                if(this.loginPageConfig.loginPageLogo){
                    this.loginPageLogoUrl = this.getFilePath(this.loginPageConfig.loginPageLogo);
                }
                if(this.loginPageConfig.loginBackGroup){
                    this.loginBackGroupUrl = this.getFilePath(this.loginPageConfig.loginBackGroup);
                }
            }
        },
        initConfigs(configsJson){
            let self=this;

            if(!configsJson){
                self.configs=this.configsJson;
                self.configs.supportGrade=self.configs.supportGrade=='true';
                self.configs.logicDel=self.configs.logicDel=='true';
                self.configs.startTreeStatistic=self.configs.startTreeStatistic=='true';
                self.configs.paramsEncrypt=self.configs.paramsEncrypt=='true';

                //短信配置
                if(!self.configs.smsType){
                    self.$set(self.configs,"smsType","qcloud");
                }
            }else {
                self.configs=configsJson;
            }
        },
        imgDel(type){
            if(type){
                this.loginPageLogoUrl = '';
                this.loginPageConfig.loginPageLogo = '';
            }else {
                this.loginBackGroupUrl = '';
                this.loginPageConfig.loginBackGroup = '';
            }

        },
        typeChange(e) {
            this.setSmsNames();
        },
        //短信显示配置
        setSmsNames(){
            if(this.configs.smsType=="qcloud"){
                this.smsAppIdName=this.i18n('argsForm.smsAppId','短信AppId');
                this.smsAppKeyName=this.i18n('argsForm.smsAppKey','短信AppKey');
            }else{
                this.smsAppIdName=this.i18n('argsForm.smsAccessKeyId','短信AppId');
                this.smsAppKeyName=this.i18n('argsForm.smsAccessKeySecret','短信AppKey');
            }
        },
        //保存配置
        saveProps:function(){
            this.$emit("saveProps");
        },
        beforeUpload(file,isBackGroup) {
            const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
            if (!isJpgOrPng) {
                this.$message.error(this.i18n('msa.jpgType','只能上传图片!'));
            }
            if(isBackGroup){
                return isJpgOrPng;
            }
            const isLt50KB = file.size / 1024  < 50;
            if (!isLt50KB) {
                this.$message.error(this.i18n('msa.jpgSize','图片必须小于50KB!'));
            }
            return isJpgOrPng && isLt50KB;
        },
        beforeUploadLogo(file) {
            return this.beforeUpload(file,false);
        },
        beforeUploadBackGroup(file) {
            return this.beforeUpload(file,true);
        },
        handleChange(info, type) {
            if (info.file.status === 'uploading') {
                //this.homePageLucentLogoLoading = true;
                this[type + 'Loading'] = true;
                return;
            }
            if (info.file.status === 'done') {
                var res=info.fileList[info.fileList.length - 1].response;
                if(res.success){
                    this[type]=res.data[0].fileId;
                    this[type + 'Url']=this.getFilePath(res.data[0].fileId);
                    this[type + 'Loading']=false;
                    this.$set(this.siteSettingConfs.loginPageConfig,type,res.data[0].fileId)
                }
            }
        },
        handleLoginPageLogo(info) {
            this.handleChange(info, 'loginPageLogo');
        },
        handleLoginBackGroup(info) {
            this.handleChange(info, 'loginBackGroup');
        },
        getCurrentI18n(){
            this.i18nCurrent= window.localStorage.getItem("language");
            if(!this.i18nCurrent){
                this.i18nCurrent=this.i18nDefault;
            }
        },
        editI18nName(record,col) {
            let self_ = this;
            var i18nJson=record[col]
            if (i18nJson && typeof i18nJson == "string"){
                //将字符串转换成对象，此处不能用JSON.parse,会转换失败
                i18nJson=eval("(" + i18nJson + ")");
            }
            if(!i18nJson){
                i18nJson={};
            }
            let conifg = {
                curVm: this,
                widthHeight: ['600px', '400px'],
                data: {
                    i18nJson: i18nJson
                }
            }
            Dialog.openI18nDialog(conifg, function (action, data) {
                self_.$set(record, col, JSON.stringify(data));
                //将双引号替换为单引号，防止双引号存储时被转义，影响json转换为对象
                record[col]=record[col].replaceAll('"',"'")
                self_[col]=self_.$i18(record[col])
                console.log(record[col])
            });
        },
        updateI18nName(record, col) {
            var i18nJson=record[col]
            if (i18nJson && typeof i18nJson == "string"){
                //将字符串转换成对象，此处不能用JSON.parse,会转换失败
                i18nJson=eval("(" + i18nJson + ")");
            }
            if(!i18nJson){
                i18nJson={};
            }
            i18nJson[this.i18nCurrent]=this[col];
            this.$set(record, col, JSON.stringify(i18nJson));
            //将双引号替换为单引号,防止双引号存储时被转义，影响json转换为对象
            record[col]=record[col].replaceAll('"',"'")
        },
        getFilePath(fileId){
            if(!fileId){
                return "";
            }
            let token = TokenUtil.getToken();
            fileId=Util.encryptWord(fileId);
            return "/api/api-system/system/core/sysFile/previewFile?fileId=" + fileId + "&accessToken=" + token;
        },
        updateConfig(saveJson,key){
            this.$emit("updateSysConfig",saveJson);
        },
        updateOsInstConfig(){
            this.$emit("updateOsInstConfig",this.inst);
        },
    },
    watch: {
        inst: {
            handler(newValue, oldValue) {
                if (!this.inst.defaultGroupIdName){
                    this.inst.defaultGroupId=""
                }
                if(this.isInstOsInst){
                    this.isInstOsInst=false;
                    return;
                }

                this.updateOsInstConfig();
            },
            deep: true
        },
        siteSetting: {
            handler(newValue, oldValue) {
                if (this.isBeginWatchNum<3) {
                    this.isBeginWatchNum++;
                    return;
                }
                let saveJson = {
                    configs:this.configs,
                    siteSetting:newValue
                }
                this.updateConfig(saveJson,"siteSetting");
            },
            deep: true
        },
        siteSettingConfs: {
            handler(newValue, oldValue) {
                if (this.isBeginWatchNum<3) {
                    this.isBeginWatchNum++;
                    return;
                }
                this.siteSetting.confs = JSON.stringify(newValue);
            },
            deep: true
        },
        configs: {
            handler(newValue, oldValue) {
                if (this.isBeginWatchNum<3) {
                    this.isBeginWatchNum++;
                    return;
                }
                let saveJson = {
                    configs:newValue,
                    siteSetting:this.siteSetting
                }
                this.updateConfig(saveJson,"configs");
            },
            deep: true
        },
        configsJson:{
            handler(newValue, oldValue) {
                this.initConfigs(newValue);
                this.setSmsNames();
            },
            deep: true
        },
        siteSettingJson:{
            handler(newValue, oldValue) {
                this.initSiteSetting();
            },
            deep: true
        }
    }
}
</script>

<style scoped>

</style>